//
//  CommentsHeader.m
//  敢唆嘛!
//
//  Created by 教主 on 15/11/27.
//  Copyright © 2015年 zms. All rights reserved.
//

#import "CommentsHeader.h"
#import "Device.h"
#import "Define.h"

@interface CommentsHeader ()
@property(nonatomic, strong)UILabel *collectNumberLabel;        // 收藏数
@property(nonatomic, strong)UILabel *recommendNumberLabel;      // 推荐数
//@property(nonatomic, strong)UIImageView *collectUserImage1;     // 收藏人1头像
//@property(nonatomic, strong)UIImageView *collectUserImage2;     // 收藏人2头像
//@property(nonatomic, strong)UIImageView *collectUserImage3;     // 收藏人3头像
//@property(nonatomic, strong)UIImageView *recommendUserImage1;     // 推荐人1头像
//@property(nonatomic, strong)UIImageView *recommendUserImage2;     // 推荐人2头像
//@property(nonatomic, strong)UIImageView *recommendUserImage3;     // 推荐人3头像
@end

@implementation CommentsHeader
{
    CGFloat x;
    CGFloat y;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self)
    {
        x = KSWidth / 19;
        y = KSWidth / 14;
        
        // 添加收藏图标
        UIImageView *collectImageView = [[UIImageView alloc] initWithFrame:CGRectMake((KSWidth - KSWidth / 20) / 2.8, y / 2, KSWidth / 20, KSWidth / 20)];
        collectImageView.image = [UIImage imageNamed:@"iconfont-xingxing-2"];
        [self.contentView addSubview:collectImageView];
        
        // 黑线
        UIView *blackLine = [[UIView alloc] initWithFrame:CGRectMake(0, collectImageView.frame.size.height + y, KSWidth, 0.5)];
        blackLine.backgroundColor = [UIColor blackColor];
        blackLine.alpha = 0.2;
        [self.contentView addSubview:blackLine];
        
        // 添加推荐图标
        UIImageView *recommendImageView = [[UIImageView alloc] initWithFrame:CGRectMake((KSWidth - KSWidth / 20) / 2.8, collectImageView.frame.size.height + y * 1.5, KSWidth / 20, KSWidth / 20)];
        recommendImageView.image = [UIImage imageNamed:@"iconfont-xunhuan2Black"];
        [self.contentView addSubview:recommendImageView];
        
        // 添加收藏数
        self.collectNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(collectImageView.frame.size.width + x * 7, y / 2, KSWidth - (collectImageView.frame.size.width - x * 2) - (KSWidth / 19) * 3 - x * 10, KSWidth / 18)];
        self.collectNumberLabel.alpha = 0.8;
        self.collectNumberLabel.font = [UIFont systemFontOfSize:KSWidth / 22];
        [self.contentView addSubview:_collectNumberLabel];
        
        // 添加推荐数
        self.recommendNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(recommendImageView.frame.size.width + x * 7, recommendImageView.frame.size.height + y * 1.5, KSWidth - (recommendImageView.frame.size.width - x * 2) - (KSWidth / 19) * 3 - x * 10, KSWidth / 18)];
        self.recommendNumberLabel.alpha = 0.8;
        self.recommendNumberLabel.font = [UIFont systemFontOfSize:KSWidth / 22];
        [self.contentView addSubview:_recommendNumberLabel];
        
//        // 添加收藏人1头像
//        self.collectUserImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(collectImageView.frame.size.width + self.collectNumberLabel.frame.size.width + x * 5, y / 2.8, KSWidth / 14, KSWidth / 14)];
//        self.collectUserImage1.layer.cornerRadius = KSWidth / 28;
//        self.collectUserImage1.layer.masksToBounds = YES; // 添加遮罩
//        [self.contentView addSubview:_collectUserImage1];
//        
//        // 添加收藏人2头像
//        self.collectUserImage2 = [[UIImageView alloc] initWithFrame:CGRectMake(collectImageView.frame.size.width + self.collectNumberLabel.frame.size.width + x * 5.5 + (KSWidth / 14), y / 2.8, KSWidth / 14, KSWidth / 14)];
//        self.collectUserImage2.layer.cornerRadius = KSWidth / 28;
//        self.collectUserImage2.layer.masksToBounds = YES; // 添加遮罩
//        [self.contentView addSubview:_collectUserImage2];
//        
//        // 添加收藏人3头像
//        self.collectUserImage3 = [[UIImageView alloc] initWithFrame:CGRectMake(collectImageView.frame.size.width + self.collectNumberLabel.frame.size.width + x * 6 + (KSWidth / 14) * 2, y / 2.8, KSWidth / 14, KSWidth / 14)];
//        self.collectUserImage3.layer.cornerRadius = KSWidth / 28;
//        self.collectUserImage3.layer.masksToBounds = YES; // 添加遮罩
//        [self.contentView addSubview:_collectUserImage3];
//        
//        // 添加推荐人1头像
//        self.recommendUserImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(recommendImageView.frame.size.width + self.recommendNumberLabel.frame.size.width + x * 5, collectImageView.frame.size.height + y * 1.35, KSWidth / 14, KSWidth / 14)];
//        self.recommendUserImage1.layer.cornerRadius = KSWidth / 28;
//        self.recommendUserImage1.layer.masksToBounds = YES; // 添加遮罩
//        self.recommendUserImage1.image = [UIImage imageNamed:@"04.jpg"];
//        [self.contentView addSubview:_recommendUserImage1];
//        
//        // 添加推荐人2头像
//        self.recommendUserImage2 = [[UIImageView alloc] initWithFrame:CGRectMake(recommendImageView.frame.size.width + self.recommendNumberLabel.frame.size.width + x * 5.5 + (KSWidth / 14), collectImageView.frame.size.height + y * 1.35, KSWidth / 14, KSWidth / 14)];
//        self.recommendUserImage2.layer.cornerRadius = KSWidth / 28;
//        self.recommendUserImage2.layer.masksToBounds = YES; // 添加遮罩
//        self.recommendUserImage2.image = [UIImage imageNamed:@"04.jpg"];
//        [self.contentView addSubview:_recommendUserImage2];
//        
//        // 添加推荐人3头像
//        self.recommendUserImage3 = [[UIImageView alloc] initWithFrame:CGRectMake(recommendImageView.frame.size.width + self.recommendNumberLabel.frame.size.width + x * 6 + (KSWidth / 14) * 2, collectImageView.frame.size.height + y * 1.35, KSWidth / 14, KSWidth / 14)];
//        self.recommendUserImage3.layer.cornerRadius = KSWidth / 28;
//        self.recommendUserImage3.layer.masksToBounds = YES; // 添加遮罩
//        self.recommendUserImage3.image = [UIImage imageNamed:@"04.jpg"];
//        [self.contentView addSubview:_recommendUserImage3];
    }
    return self;
}

- (void)setHomeModel:(HomeModel *)model
{
    self.collectNumberLabel.text = [NSString stringWithFormat:@"%ld人收藏",model.collectNumber];
    self.recommendNumberLabel.text = [NSString stringWithFormat:@"%ld次推荐",model.recommendNumber];
}

- (void)setRealityModel:(RealityModel *)model
{
    self.collectNumberLabel.text = [NSString stringWithFormat:@"%ld人收藏",model.collectNumber];
    self.recommendNumberLabel.text = [NSString stringWithFormat:@"%ld次推荐",model.recommendNumber];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
